Skip to content

batch: reverse with the type's operations and the close cascade - #50

Merged
jallers merged 2 commits into
proposed_type_script_api_versionfrom
ccr-21370f44-nm031v
Nov 11, 2026
Merged

jallers merged 2 commits into
proposed_type_script_api_versionfrom
ccr-21370f44-nm031v

Conversation

@jallers

@jallers jallers commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Fixes the SDK side of versionone/gh-v1#21 and versionone/gh-v1#48.

Changes

Reverse uses the type's operations (gh-v1#21)

  • AssetType.Operations (bare names, from meta.v1's Operations keys) and Schema.canOperate(type, op), which returns undefined when it doesn't know.
  • reverseOf takes an optional ReverseContext. When a created asset's type has no Delete (a Conversation lists only Join/Leave), the reverse adds a note instead of a command the server would refuse. An inverse operation the type lacks gets the same treatment. Without schema info the behaviour is unchanged.
  • receipt.failed: touched assets whose command the server reports as failed. They are no longer also listed in skipped as "changed since the snapshot".

Cascade-aware undo of a close (gh-v1#48)

  • Core's Inactivate/QuickClose also close the asset's open descendants, but Reactivate reopens only the asset it names.
  • Before the send, receipt.openDescendants records each closing target's open descendants, top down through Children.
  • After the send, receipt.cascaded records the descendants that are now closed. The reverse reactivates the parent first, then those descendants. Their after-stamps are recorded, so batch.reversible checks them for drift.
  • If the cascade can't be read back, the reverse says in a note what it did not reopen.
  • QuickClose now has Reactivate as its inverse.

Testing

  • npm run verify passes: typecheck, build, 131 unit tests, 4 of them new.
  • New live tests in test/integration/batch.test.ts, run against v1sdktesting:
    • Inactivate and QuickClose on a Story close its open Task.
    • The reverse reopens the Story and then the Task, and a Task closed before the batch stays closed.
    • A created Conversation is left out of the reverse with a note, and undoing its Expression reports no failure.
  • The full integration suite passes: 31 passed, 3 skipped.

Not included

gh-v1#49 (use Moment instead of ChangeDate for the staleness check) conflicts with guard.ts and test/integration/guard.test.ts. Those show that a filter on an earlier Moment selects the asset as it was then, so it can't detect a stale write. It needs its repro before any change.


Generated by Claude Code

- reverseOf takes the type's Operations from meta. Schema carries them
  now (AssetType.Operations, Schema.canOperate). A created asset whose
  type has no Delete (Conversation lists only Join and Leave) gets a note
  instead of a command the server refuses. An inverse operation the type
  lacks is handled the same way. (versionone/gh-v1#21)
- An asset whose command the server reports as failed goes in
  receipt.failed and is no longer also listed in skipped as "changed
  since the snapshot". (versionone/gh-v1#21)
- Undoing Inactivate or QuickClose now reopens what the close cascaded
  to. Before the send, the receipt records each closing target's open
  descendants, top down through Children (openDescendants). After it,
  the receipt records the ones now closed (cascaded), and the reverse
  reactivates the parent and then those, in that order. Their after-stamps
  are recorded too, so batch.reversible checks them for drift. If they
  can't be read back, the reverse notes what it did not reopen.
  QuickClose gets Reactivate as its inverse. (versionone/gh-v1#48)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NSWj8mSZ8LrMj16R2cozL
Run against v1sdktesting. Inactivate and QuickClose on a Story close its
open Task as well. The receipt records that Task as cascaded, and the
reverse reopens the Story and then the Task. A Task that was closed
before the batch stays closed. A created Conversation is left out of the
reverse with a note, and undoing its Expression reports no failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016NSWj8mSZ8LrMj16R2cozL
@jallers
jallers merged commit 1d39425 into proposed_type_script_api_version Nov 11, 2026
4 checks passed
@jallers
jallers deleted the ccr-21370f44-nm031v branch November 11, 2026 16:29
@jallers jallers mentioned this pull request Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants